﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.TextUtils;
using CatUtils.Utils.SpecialUtils.View;
using System;
using System.Windows.Forms;

namespace RabbitDownload.WebSite.Pixiv.PixivTag
{
    public partial class PixivTagControl : UserControl
    {
        public PixivTagControl()
        {
            InitializeComponent();
            InitView();
        }

        private void InitView()
        {
            PixivStaticValue.BlockComic = checkBox1.Checked;
            PixivStaticValue.ExcludeOpenFlag = checkBox3.Checked;
            TimeGroupShow();
        }

        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (checkBox2.Checked)
            {
                PixivTagScanner.StartForTimeMode(textBox1.Text, TextHelper.StringToInt(textBox2.Text), TextHelper.StringToInt(textBox3.Text),
                     TextHelper.StringToInt(textBox4.Text), TextHelper.StringToInt(textBox5.Text),

                    dateTimePicker1.Value, TextHelper.StringToInt(textBox6.Text));
            }
            else
            {
                PixivTagScanner.Start(textBox1.Text, TextHelper.StringToInt(textBox2.Text), TextHelper.StringToInt(textBox3.Text), TextHelper.StringToInt(textBox4.Text), TextHelper.StringToInt(textBox5.Text));
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            PixivStaticValue.BlockComic = checkBox1.Checked;
        }

        private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
        {
            Helper.ViewHelper.TextBoxHelper.PrintCount(e);
        }

        private void textBox6_TextChanged(object sender, EventArgs e)
        {
            if (TextHelper.StringToInt(textBox6.Text) > 364)
            {
                MessageHelper.Alert("警告！时间不能超过363");
            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            TimeGroupShow();
        }

        private void TimeGroupShow()
        {
            if (checkBox2.Checked)
            {
                groupBox1.Visible = true;
            }
            else
                groupBox1.Visible = false;
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            PixivStaticValue.ExcludeOpenFlag = checkBox3.Checked;
        }
    }
}